﻿using System;
using System.Data;
using System.Data.SqlClient;

namespace UDS.Components
{
    /// <summary>
    /// BBS 的摘要说明。
    /// </summary>
    public class BBSClass
    {
        #region 判断是否有BBS管理权限

        /// <summary>
        /// 判断是否有管理权限
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="classid">The id of the feature.</param>
        /// <returns>bool</returns>
        public bool AdminBBS(string username, int classid)
        {
            if (classid != 0)
            {
                return AssignRights.IsAccessAllowed(username, classid, PermissionType.ManagePositionAndBBS);
            }

            return false;
        }

        #endregion

        #region 判断是否有发布系统公告权限

        /// <summary>
        /// 判断是否有发布系统公告权限
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="classid">The id of the feature.</param>
        /// <returns>bool</returns>
        public bool AdminSysBulletin(string username, int classid)
        {
            if (classid != 0)
            {
                return AssignRights.IsAccessAllowed(username, classid, PermissionType.ManageSysBulletin);
            }
            return (false);
        }

        #endregion

        #region 判断是否是板块斑竹

        /// <summary>
        /// 判断是否是板块斑竹
        /// </summary>
        /// <param name="boardid">板块ID</param>
        /// <param name="username">用户名</param>
        /// <returns></returns>
        public bool IsBoardMaster(int boardid, string username)
        {
            var db = new Database();
            var parameters = new[]
            {
                Database.MakeInParam("@board_id", SqlDbType.Int, 4, boardid),
                Database.MakeInParam("@staff_name", SqlDbType.NVarChar, 100, username)
            };
            try
            {
                if (db.RunProc("dbo.sproc_BBSISBoardMaster", parameters) == 1)
                {
                    return (true);
                }
                return (false);
            }
            catch (Exception ex)
            {
                Logger.Log(ex.Message);
                throw new Exception("BBS斑竹权限判断错误!", ex);
            }
        }

        #endregion

        #region 新增分栏信息

        //给uds_bbs_catalog表,新增记录
        public bool AddBBSCatalog(BBSCatalog BBSCatalog) //string CatalogName,string CatalogDescription
        {
            //参数 CatalogName 表示BBS中的title , 参数 CatalogDescription 表示BBS中的content
            //给存储过程传递参数
            var data = new Database();
            var parameters = new[]
            {
                Database.MakeInParam("@title", SqlDbType.NVarChar, 300, BBSCatalog.CatalogName),
                Database.MakeInParam("@content", SqlDbType.NText, 16, BBSCatalog.CatalogDescription),
            };
            data.RunProc("dbo.sproc_BBS_AddCatalog", parameters);
            return true;
        }

        #endregion

        #region 查询BBS贴子

        public SqlDataReader Find(string key, BBSSearchOption option, DataTable boards)
        {
            string boardids = "";
            string sql = "select * from UDS_Bbs_ForumItem";

            switch (option.searchtype)
            {
                case BBSSearchType.author:
                    sql += " where sender like '%" + key + "%'";
                    break;
                case BBSSearchType.title:
                    sql += " where title like '%" + key + "%'";
                    break;
            }

            if (option.BoardID != 0)
            {
                sql += " and board_id=" + option.BoardID;
            }
            else
            {
                foreach (DataRow row in boards.Rows)
                {
                    boardids += row["board_id"] + ",";
                }

                if (boardids != "")
                {
                    boardids = boardids.Substring(0, boardids.Length - 1);
                }


                sql += " and board_id in (" + boardids + ")";
            }
            if (option.TimeBound != TimeSpan.MaxValue)
            {
                //计算时间段
                sql += " and datediff(d,send_time,getdate())< " + option.TimeBound.Days;
            }


            var db = new Database();
            var parameters = new[]
            {
                Database.MakeInParam("@SQL", SqlDbType.NText, 5000, sql),
            };

            return db.RunDataReader("dbo.sproc_RunSQL", parameters);
        }

        #endregion

        #region 修改分栏信息时根据CatalogID显示数据

        public SqlDataReader GetModifyBBSCatalog(int m_CatalogID)
        {
            //参数CatalogID表示存储过程中的@catalog_id int	分栏ID
            var data = new Database();
            var parameters = new[]
            {
                Database.MakeInParam("@catalog_id", SqlDbType.Int, 4, m_CatalogID),
            };
            try
            {
                return data.RunDataReader("dbo.sproc_BBS_GetCatalogInfo", parameters);
            }
            catch (Exception ex)
            {
                Logger.Log(ex.ToString());
                //				throw new Exception("BBS类别增加错误!",ex);
                return null;
            }
        }

        #endregion

        #region 修改（编缉分栏信息）

        //更新分类栏信息
        public bool EditBBSCatalog(BBSCatalog BBSCatalog)
        {
            //	@catalog_id int,				:	分栏ID
            //	@catalog_name varchar(300),		:	分栏名称
            //	@catalog_description varchar(300)	:	分栏介绍
            // 给存储过程传递参数
            var data = new Database();
            var parameters = new[]
            {
                Database.MakeInParam("@catalog_id", SqlDbType.Int, 4, BBSCatalog.CatalogID),
                Database.MakeInParam("@catalog_name", SqlDbType.NVarChar, 300, BBSCatalog.CatalogName),
                Database.MakeInParam("@catalog_description", SqlDbType.NVarChar, 300, BBSCatalog.CatalogDescription),
            };
            try
            {
                data.RunProc("dbo.sproc_BBS_UpdateCatalogInfo", parameters);
                return true;
            }
            catch (Exception ex)
            {
                Logger.Log(ex.ToString());
                throw new Exception("BBS类别编缉错误!", ex);
            }
        }

        #endregion

        #region 删除分栏（分栏信息）

        public int DelBBSCatalog(int catalog_id)
        {
            var db = new Database();
            var parameters = new[]
            {
                Database.MakeInParam("@catalog_id ", SqlDbType.Int, 4, catalog_id)
            };
            return (db.RunProc("dbo.sproc_BBS_DeleteCatalog", parameters));
        }

        #endregion

        #region 在分类中新增一个板块（添加板块）

        //在BBS大类中 添加板块
        public bool BBSAddBoard(BBSBoard BBSBoard)
        {
            //需向存储过程传递的参数如下
            //@catalog_id (int) 分类ID号, @title (varchar(300)) 抬头的名称, @content ntext 板块内容, @boardtype bit 板块类型

            var data = new Database();
            var parameters = new[]
            {
                Database.MakeInParam("@catalog_id", SqlDbType.Int, 4, BBSBoard.CatalogID),
                Database.MakeInParam("@title", SqlDbType.NVarChar, 300, BBSBoard.BoardName),
                Database.MakeInParam("@content", SqlDbType.NText, 16, BBSBoard.BoardDescription),
                Database.MakeInParam("@boardtype", SqlDbType.Bit, 1, BBSBoard.BoardType),
            };

            data.RunProc("dbo.sproc_BBS_AddBoard", parameters);
            return true;
        }

        #endregion

        #region 修改板块时根据BoardID显示数据

        public SqlDataReader GetModifyBBSBoard(int m_BoardID)
        {
            //参数m_BoardID表示存储过程中的@board_id int	:	板块ID
            var data = new Database();
            var parameters = new[]
            {
                Database.MakeInParam("@board_id", SqlDbType.Int, 4, m_BoardID),
            };
            try
            {
                return data.RunDataReader("dbo.sproc_BBS_GetBoardInfo", parameters);
            }
            catch (Exception ex)
            {
                Logger.Log(ex.ToString());
                //				throw new Exception("BBS类别增加错误!",ex);
                return null;
            }
        }

        #endregion

        #region 修改（编缉板块）

        //更新板块信息
        public bool EditBBSBoard(BBSBoard BBSBoard)
        {
            //@board_id int,				:	被更新的板块ID			
            //@board_name varchar(300)		:	板块名称
            //@board_description varchar(300),	:	板块介绍
            //@board_type bit				:	板块类型(公共型，私有型)
            // 给存储过程传递参数
            var data = new Database();
            var parameters = new[]
            {
                Database.MakeInParam("@board_id", SqlDbType.Int, 4, BBSBoard.BoardID),
                Database.MakeInParam("@board_name", SqlDbType.NVarChar, 300, BBSBoard.BoardName),
                Database.MakeInParam("@board_description", SqlDbType.NVarChar, 300,
                    BBSBoard.BoardDescription),
                Database.MakeInParam("@board_type", SqlDbType.Bit, 1, BBSBoard.BoardType),
            };
            //try
            {
                data.RunProc("dbo.sproc_BBS_UpdateBoardInfo", parameters);
                return true;
            }
            //catch (Exception ex)
        }

        #endregion

        #region 删除（删除板块）

        public int DelBBSBoard(int board_id)
        {
            //@board_id 	:	板块ID
            var db = new Database();
            var parameters = new[]
            {
                Database.MakeInParam("@board_id ", SqlDbType.Int, 4, board_id)
            };
            return (db.RunProc("dbo.sproc_BBS_DeleteBoard", parameters));
        }

        #endregion

        #region 斑竹操作

        //得到版块版主
        public SqlDataReader GetBoardMaster()
        {
            var data = new Database();
            //var parameters = new[] {
            //						   Database.MakeInParam("@board_id",  SqlDbType.Int, 4, master.BoardID),
            //};
            try
            {
                return data.RunDataReader("dbo.sproc_BBS_GetAllBoardMaster");
            }
            catch (Exception ex)
            {
                Logger.Log(ex.ToString());
                return null;
            }
        }


        //删除版主
        public int DeleteBoardMaster(BBSBoardmaster master)
        {
            //参数:
            //      @BoardID 	:	版块ID
            //   	@StaffID 	:	员工ID
            var data = new Database();
            var parameters = new[]
            {
                Database.MakeInParam("@BoardID", SqlDbType.Int, 4, master.BoardID),
                Database.MakeInParam("@StaffID", SqlDbType.Int, 4, master.StaffID),
            };
            return (data.RunProc("dbo.sproc_BBS_DeleteBoardMaster", parameters));
        }


        //设置版主
        public bool SetupBoardMaster(BBSBoardmaster master)
        {
            //参数:	
            //       @BoardID int		:	板块ID
            //     	@StaffID int		:	员工ID
            var data = new Database();
            var parameters = new[]
            {
                Database.MakeInParam("@BoardID", SqlDbType.Int, 4, master.BoardID),
                Database.MakeInParam("@StaffID", SqlDbType.Int, 4, master.StaffID),
            };
            try
            {
                data.RunProc("dbo.sproc_BBS_SetupBoardMaster", parameters);
                return true;
            }
            catch (Exception ex)
            {
                Logger.Log(ex.ToString());
                return false;
            }
        }

        #endregion

        #region 私有板块成员操作

        //得到版块成员
        public SqlDataReader GetBoardMember()
        {
            var data = new Database();
            try
            {
                return data.RunDataReader("dbo.sproc_BBS_GetAllBoardMember");
            }
            catch (Exception ex)
            {
                Logger.Log(ex.ToString());
                return null;
            }
        }


        //删除成员
        public int DeleteBoardMember(BBSBoardmember member)
        {
            //参数:
            //      @BoardID 	:	版块ID
            //   	@StaffID 	:	员工ID
            var data = new Database();
            var parameters = new[]
            {
                Database.MakeInParam("@StaffID", SqlDbType.Int, 4, member.StaffID)
            };
            return (data.RunProc("dbo.sproc_BBS_DeleteBoardMember", parameters));
        }


        //设置成员
        public bool SetupBoardMember(int boardid, int staffid)
        {
            //参数:	
            //       @BoardID int		:	板块ID
            //     	@StaffID int		:	员工ID
            var data = new Database();
            var parameters = new[]
            {
                Database.MakeInParam("@BoardID", SqlDbType.Int, 4, boardid),
                Database.MakeInParam("@StaffID", SqlDbType.Int, 4, staffid),
            };
            try
            {
                data.RunProc("dbo.sproc_BBS_SetupBoardMember", parameters);
                return true;
            }
            catch (Exception ex)
            {
                Logger.Log(ex.ToString());
                return false;
            }
        }

        #endregion

        #region 显示所有分栏信息

        public SqlDataReader GetBBSCatalog()
        {
            //参数:			无
            var data = new Database();

            try
            {
                return data.RunDataReader("dbo.sproc_GetBBSCatalog");
            }
            catch (Exception ex)
            {
                Logger.Log(ex.ToString());
                return null;
            }
        }

        #endregion

        #region 显示个人的分类栏的版块

        public SqlDataReader GetBBSBoard(string m_StaffName)
        {
            //参数:  m_StaffName        :   员工姓名
            //@catalog_id int			:	分类栏ID
            // @staff_name varchar(50)=''	:	员工姓名
            var data = new Database();
            var parameters = new[]
            {
                Database.MakeInParam("@staff_name", SqlDbType.NVarChar, 50, m_StaffName)
            };
            try
            {
                return data.RunDataReader("dbo.sproc_BBS_GetAllBoardByStaff", parameters);
            }
            catch (Exception ex)
            {
                Logger.Log(ex.ToString());
                return null;
            }
        }

        #endregion

        #region 显示所有板块

        public SqlDataReader GetAllBBSBoard()
        {
            var data = new Database();
            try
            {
                return data.RunDataReader("dbo.sproc_BBS_GetAllBoard");
            }
            catch (Exception ex)
            {
                Logger.Log(ex.ToString());
                return null;
            }
        }

        #endregion

        #region 显示该版块的所有帖子

        public SqlDataReader GetBBSForumItem(BBSForumItem item)
        {
            //参数:	@board_id int		:	该版块ID
            var data = new Database();
            var parameters = new[]
            {
                Database.MakeInParam("@board_id", SqlDbType.Int, 4, item.BoardID),
            };
            try
            {
                return data.RunDataReader("dbo.sproc_GetBBSForumItem", parameters);
            }
            catch (Exception ex)
            {
                Logger.Log(ex.ToString());
                return null;
            }
        }

        #endregion

        #region 得到所有系统公告

        /// <summary>
        /// 得到所有系统公告
        /// </summary>
        /// <returns></returns>
        public SqlDataReader GetSysBulletin()
        {
            var data = new Database();
            try
            {
                var parameters = new[]
                {
                    Database.MakeInParam("@type", SqlDbType.Int, 4, -1),
                };
                return data.RunDataReader("dbo.sproc_BBS_GetBulletin", parameters);
            }
            catch (Exception ex)
            {
                Logger.Log(ex.ToString());
                return null;
            }
        }

        #endregion

        #region 得到所有桌面公告

        /// <summary>
        /// 得到所有桌面公告
        /// </summary>
        /// <returns></returns>
        public SqlDataReader GetDeskTopBulletin()
        {
            var data = new Database();
            try
            {
                var parameters = new[]
                {
                    Database.MakeInParam("@type", SqlDbType.Int, 4, -2),
                };
                return data.RunDataReader("dbo.sproc_BBS_GetBulletin", parameters);
            }
            catch (Exception ex)
            {
                Logger.Log(ex.ToString());
                return null;
            }
        }

        #endregion

        #region 得到板块公告

        /// <summary>
        /// 得到板块公告
        /// </summary>
        /// <param name="boardid">板块id,=0则取出所有板块的公告</param>
        /// <returns></returns>
        public SqlDataReader GetBulletin(int boardid)
        {
            var data = new Database();
            try
            {
                var parameters = new[]
                {
                    Database.MakeInParam("@type", SqlDbType.Int, 4, boardid),
                };
                return data.RunDataReader("dbo.sproc_BBS_GetBulletin", parameters);
            }
            catch (Exception ex)
            {
                Logger.Log(ex.ToString());
                return null;
            }
        }

        #endregion

        #region 读取论坛帖子

        public SqlDataReader ReadBBSForumItem(BBSForumItem item)
        {
            //参数:			@item_id int		:	帖子ID	
            var data = new Database();
            var parameters = new[]
            {
                Database.MakeInParam("@item_id", SqlDbType.Int, 4, item.ItemID),
            };
            try
            {
                return data.RunDataReader("dbo.sproc_ReadBBSForumItem", parameters);
            }
            catch (Exception ex)
            {
                Logger.Log(ex.ToString());
                return null;
            }
        }

        public void ReadBBSForumItemStruct(BBSForumItem item)
        {
            //参数:			@item_id int		:	帖子ID	
            var data = new Database();
            var parameters = new[]
            {
                Database.MakeInParam("@item_id", SqlDbType.Int, 4, item.ItemID),
            };
            try
            {
                using (SqlDataReader dataReader = data.RunDataReader("dbo.sproc_ReadBBSForumItem", parameters))
                {
                    while (dataReader.Read())
                    {
                        item.BoardID = Int32.Parse(dataReader["board_id"].ToString());
                        item.Title = dataReader["title"].ToString();
                        item.Content = dataReader["content"].ToString();
                        item.Sender = dataReader["sender"].ToString();
                        item.SendTime = DateTime.Parse(dataReader["send_time"].ToString());
                        item.HitTimes = Int32.Parse(dataReader["hit_times"].ToString());
                        item.ReplayTimes = Int32.Parse(dataReader["replay_times"].ToString());
                        item.LastReplayer = dataReader["last_replayer"].ToString();
                        item.LastReplayTime = dataReader["last_replay_time"].ToString();
                        item.IP = dataReader["ip"].ToString();
                        item.Bulletin = Convert.ToBoolean(dataReader["bulletin"]);
                        item.SysBulletin = Convert.ToBoolean(dataReader["sysbulletin"]);
                        item.DeskTop = Convert.ToBoolean(dataReader["desktop"]);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex.ToString());
            }
        }

        #endregion

        #region 修改论坛帖子

        public void ModBBSForumItem(BBSForumItem item)
        {
            //参数:			@item_id int		:	帖子ID	
            var data = new Database();
            var parameters = new[]
            {
                Database.MakeInParam("@item_id", SqlDbType.Int, 4, item.ItemID),
                Database.MakeInParam("@board_id", SqlDbType.Int, 4, item.BoardID),
                Database.MakeInParam("@title", SqlDbType.NVarChar, 300, item.Title),
                Database.MakeInParam("@content", SqlDbType.NText, 5000, item.Content),
                Database.MakeInParam("@sender", SqlDbType.NVarChar, 50, item.Sender),
                Database.MakeInParam("@send_time", SqlDbType.DateTime, 8, item.SendTime),
                Database.MakeInParam("@hit_times", SqlDbType.Int, 4, item.HitTimes),
                Database.MakeInParam("@replay_times", SqlDbType.Int, 4, item.ReplayTimes),
                Database.MakeInParam("@last_replayer", SqlDbType.NVarChar, 50, item.LastReplayer),
                Database.MakeInParam("@last_replay_time", SqlDbType.DateTime, 8,
                    item.LastReplayTime == "" ? Convert.DBNull : item.LastReplayTime)
                ,
                Database.MakeInParam("@ip", SqlDbType.NVarChar, 50, item.IP),
                Database.MakeInParam("@bulletin", SqlDbType.Bit, 4, item.Bulletin),
                Database.MakeInParam("@sysbulletin", SqlDbType.Bit, 4, item.SysBulletin),
                Database.MakeInParam("@desktop", SqlDbType.Bit, 4, item.DeskTop),
            };
            try
            {
                data.RunProc("dbo.sproc_BBS_UpdateItemInfo", parameters);
            }
            catch (Exception ex)
            {
                Logger.Log(ex.ToString());
            }
        }

        #endregion

        #region 读取帖子回复

        public SqlDataReader ReadBBSForumItemReplay(BBSForumItem item)
        {
            //参数:			@item_id int		:	帖子ID
            var data = new Database();
            var parameters = new[]
            {
                Database.MakeInParam("@item_id", SqlDbType.Int, 4, item.ItemID),
            };
            try
            {
                return data.RunDataReader("dbo.sproc_ReadBBSForumItemReplay", parameters);
            }
            catch (Exception ex)
            {
                Logger.Log(ex.ToString());
                return null;
            }
        }

        #endregion

        #region 删除回复

        public void DelReplay(BBSReplay replay)
        {
            var data = new Database();
            var parameters = new[]
            {
                Database.MakeInParam("@replayid", SqlDbType.Int, 4, replay.ReplayId),
                Database.MakeInParam("@itemid", SqlDbType.Int, 4, replay.ItemID)
            };
            data.RunProc("dbo.sproc_BBS_DeleteReplay", parameters);
        }

        #endregion

        #region 回复贴子

        public int ReplayItem(BBSReplay replay)
        {
            var data = new Database();
            var parameters = new[]
            {
                Database.MakeInParam("@item_id", SqlDbType.Int, 4, replay.ItemID),
                Database.MakeInParam("@content", SqlDbType.NText, 5000, replay.Content),
                Database.MakeInParam("@replayer", SqlDbType.NVarChar, 300, replay.Replayer),
                Database.MakeInParam("@replay_ip", SqlDbType.NVarChar, 50, replay.ReplayId)
            };
            try
            {
                return (data.RunProc("dbo.sproc_BBSReplay", parameters));
            }
            catch (Exception ex)
            {
                Logger.Log(ex.ToString());
                throw new Exception("回复出错！");
            }
        }

        #endregion

        #region 发布贴子

        public int SendItem(BBSForumItem item)
        {
            var data = new Database();
            var parameters = new[]
            {
                Database.MakeInParam("@board_id", SqlDbType.Int, 4, item.BoardID),
                Database.MakeInParam("@title", SqlDbType.NVarChar, 300, item.Title),
                Database.MakeInParam("@content", SqlDbType.NText, 5000, item.Content),
                Database.MakeInParam("@sender", SqlDbType.NVarChar, 100, item.Sender),
                Database.MakeInParam("@ip", SqlDbType.NVarChar, 50, item.IP),
                Database.MakeInParam("@bulletin", SqlDbType.Bit, 1, item.Bulletin),
                Database.MakeInParam("@sysbulletin", SqlDbType.Bit, 1, item.SysBulletin),
                Database.MakeInParam("@desktop", SqlDbType.Bit, 1, item.DeskTop)
            };
            try
            {
                return (data.RunProc("dbo.sproc_BBSAddItem", parameters));
            }
            catch (Exception ex)
            {
                Logger.Log(ex.ToString());
                throw new Exception("发布出错！");
            }
        }

        #endregion

        #region 增加板主

        public void AddBoardMaster(int boardid, int staffid)
        {
            var data = new Database();
            var parameters = new[]
            {
                Database.MakeInParam("@BoardID", SqlDbType.Int, 4, boardid),
                Database.MakeInParam("@StaffID", SqlDbType.Int, 4, staffid)
            };
            data.RunProc("dbo.sproc_BBS_SetupBoardMaster", parameters);
        }

        #endregion

        #region 删除板主

        public void DelBoardMaster(int boardid, int staffid)
        {
            var data = new Database();
            var parameters = new[]
            {
                Database.MakeInParam("@BoardID", SqlDbType.Int, 4, boardid),
                Database.MakeInParam("@StaffID", SqlDbType.Int, 4, staffid)
            };
            data.RunProc("dbo.sproc_BBS_DeleteBoardMaster", parameters);
        }

        #endregion

        #region 移动论坛贴子

        public void MoveBoardItem(BBSForumItem olditem, BBSForumItem newitem)
        {
            var data = new Database();
            var parameters = new[]
            {
                Database.MakeInParam("@item_id", SqlDbType.Int, 4, olditem.ItemID),
                Database.MakeInParam("@to_board_id", SqlDbType.Int, 4, newitem.BoardID)
            };
            data.RunProc("dbo.sproc_BBSMoveItem", parameters);
        }

        #endregion

        #region 删除论坛贴子

        public void DelItem(BBSForumItem item)
        {
            var data = new Database();
            var parameters = new[]
            {
                Database.MakeInParam("@item_id", SqlDbType.Int, 4, item.ItemID)
            };
            data.RunProc("dbo.sproc_BBSDeleteItem", parameters);
        }

        #endregion

        #region 得到所有论坛

        public SqlDataReader GetAllBoard()
        {
            var data = new Database();
            return data.RunDataReader("dbo.sproc_BBSGetMoveToBoard");
        }

        #endregion

        #region 上传一个文件得到id号

        public int InsertFile(string name, string extension)
        {
            var data = new Database();
            var parameters = new[]
            {
                Database.MakeInParam("@name", SqlDbType.NVarChar, 200, name),
                Database.MakeInParam("@extension", SqlDbType.NVarChar, 100, extension)
            };

            return (data.RunProc("dbo.sproc_BBS_AddFile", parameters));
        }

        #endregion

        #region 根据id得到上传附件信息

        public SqlDataReader GetAttachmentByID(int id)
        {
            var data = new Database();
            var parameters = new[]
            {
                Database.MakeInParam("@id", SqlDbType.Int, 4, id)
            };
            return data.RunDataReader("dbo.sproc_BBS_GetAttachmentByID", parameters);
        }

        #endregion
    }
}